package com.qidian.mes.md.service.impl;

import com.alibaba.fastjson2.JSON;
import com.qidian.mes.md.mapper.MdWorkshopMapper;
import com.qidian.mes.md.service.MdWorkshopService;
import com.qidian.mes.pojo.MdWorkshop;
import com.qidian.mes.util.pojo.QdResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: 小可怎么都睡不够
 * @Description:
 * @Time: 2024-04-10 11:08
 **/
@Service
public class MdWorkshopServiceImpl implements MdWorkshopService {

    @Autowired
    MdWorkshopMapper mdWorkshopMapper;

    @Override
    public QdResult insertMdWorkshop(String data) {
        mdWorkshopMapper.insertMdWorkshop(JSON.parseObject(data, MdWorkshop.class));
        return QdResult.success();
    }

    @Override
    public QdResult deleteMdWorkshopById(Integer idWorkshop,Integer status) {
        mdWorkshopMapper.deleteMdWorkshopById(idWorkshop,status);
        return QdResult.success();
    }

    @Override
    public QdResult updateMdWorkshop(String data) {
        mdWorkshopMapper.updateMdWorkshop(JSON.parseObject(data, MdWorkshop.class));
        return QdResult.success();
    }

    @Override
    public QdResult getMdWorkshopById(Integer idWorkshop) {
        return QdResult.success(mdWorkshopMapper.getMdWorkshopById(idWorkshop));
    }

    @Override
    public QdResult getMdWorkshopsByName(String emp, String name, Integer page, Integer limit) {
        return QdResult.success(mdWorkshopMapper.getMdWorkshopsByName(emp, name, (page - 1) * limit, limit));
    }

    @Override
    public QdResult getCount() {
        return QdResult.success(mdWorkshopMapper.getCount());
    }

    @Override
    public QdResult getMdWorkshops() {
        return QdResult.success(mdWorkshopMapper.getMdWorkshops());
    }

}
